public bool Matches(string token) { if (InputParser.IsShortFlag(token)) { return(token == ShortForm); } var lowerToken = token.ToLower(); return(lowerToken == LongForm.ToLower()); }
/// <summary> /// Initializes a new instance of the <see cref="Fixed26Dot6"/> struct. /// </summary> /// <param name="form">form</param>/// /// <param name="value">A floating point value.</param> public Fixed26Dot6(LongForm form, float value) { this.form = form; if (form == LongForm.Long4) { this.value8 = 0; this.value = (FT_F26Dot6_4)(value * 64); } else { this.value = 0; this.value8 = (FT_F26Dot6_8)(value * 64); } }
/// <summary> /// Creates a <see cref="Fixed26Dot6"/> from an int containing a 26.6 value. /// </summary> /// <param name="form">A <see cref="LongForm"/> form </param>/// /// /// <param name="value">A 26.6 value.</param> /// <returns>An instance of <see cref="Fixed26Dot6"/>.</returns> public static Fixed26Dot6 FromRawValue(this LongForm form, int value) { Fixed26Dot6 f = new Fixed26Dot6(form, 0); if (form == LongForm.Long4) { f.value = value; } else { f.value8 = value; } return(f); }
/// <summary> /// Initializes a new instance of the <see cref="Fixed26Dot6"/> struct. /// </summary> /// <param name="form">form</param> /// <param name="value">An integer value.</param> public Fixed26Dot6(LongForm form, int value) { this.form = form; if (form == LongForm.Long4) { this.value8 = 0; this.value = value << 6; } else { this.value = 0; this.value8 = value << 6; } }
public bool Equals(string str) { if (str == null) { return(false); } if (str.StartsWith("-")) { str = str.Substring(1); } return(ShortForm.ToString().Equals(str) || LongForm.Equals(str)); }
public FontFace(LongForm form) { Form = form; }
static PackedFont load_font(FontLibrary library, string path, LongForm form, uint alignment) { var face = new FontFace(form); FT_CHECK(face.NewFace(library, path, 0)); FT_CHECK(face.SetCharSize( form.FromInt32(0), form.FromInt32(1000), 96, 96)); uint total_points = 0; uint total_cells = 0; var glyph_infos = new fd_HostGlyphInfo[NUMBER_OF_GLYPHS]; var outlines = new fd_Outline[NUMBER_OF_GLYPHS]; for (uint i = 0; i < NUMBER_OF_GLYPHS; i++) { char c = Convert.ToChar(Convert.ToInt32(' ') + i); Console.WriteLine("{0}", c); //fd_Outline o = r.outlines[i]; //fd_HostGlyphInfo hgi = r.glyph_infos[i]; var glyph_index = face.GetCharIndex(c); FT_CHECK(face.LoadGlyph(glyph_index, LoadFlags.NoHinting, LoadTarget.Default)); var g = face.GetGlyph(c); outlines[i] = g.Outline; glyph_infos[i] = new fd_HostGlyphInfo { bbox = outlines[i].bbox, advance = g.Advance, }; total_points += outlines[i].num_of_points; total_cells += outlines[i].cell_count_x * outlines[i].cell_count_y; } uint glyph_info_size = (UInt32)Marshal.SizeOf <fd_DeviceGlyphInfo>() * NUMBER_OF_GLYPHS; uint glyph_cells_size = sizeof(UInt32) * total_cells; var result = new PackedFont { no_of_glyphs = NUMBER_OF_GLYPHS, glyph_infos = glyph_infos, glyph_info_size = glyph_info_size, glyph_cells_size = glyph_cells_size, glyph_points_size = (UInt32)Marshal.SizeOf <Vector2>() * total_points, alignment = alignment, glyph_info_offset = 0U, glyph_cells_offset = align_uint32(glyph_info_size, alignment), glyph_points_offset = align_uint32(glyph_info_size + glyph_cells_size, alignment), }; // UInt32 alignment = r->device_properties.limits.minStorageBufferOffsetAlignment; result.glyph_data_size = align_uint32(result.glyph_points_offset + result.glyph_points_size, alignment); result.glyphData = new byte[result.glyph_data_size]; Span <byte> dstBuffer = result.glyphData; var dstGlyphInfo = MemoryMarshal.Cast <byte, fd_DeviceGlyphInfo>( dstBuffer.Slice((int)result.glyph_info_offset, (int)result.glyph_info_size) ); var dstCells = MemoryMarshal.Cast <byte, uint>( dstBuffer.Slice((int)result.glyph_cells_offset, (int)result.glyph_cells_size) ); var dstPoints = MemoryMarshal.Cast <byte, Vector2>( dstBuffer.Slice((int)result.glyph_points_offset, (int)result.glyph_points_size) ); UInt32 point_offset = 0; UInt32 cell_offset = 0; for (var i = 0; i < NUMBER_OF_GLYPHS; i++) { dstGlyphInfo[i] = new fd_DeviceGlyphInfo { bbox = outlines[i].bbox, cell_info = new fd_CellInfo { cell_count_x = outlines[i].cell_count_x, cell_count_y = outlines[i].cell_count_y, point_offset = point_offset, cell_offset = cell_offset, } }; uint cell_count = outlines[i].cell_count_x * outlines[i].cell_count_y; // memcpy(dstCells + cell_offset, o->cells, sizeof(uint32_t) * cell_count); { var dst = dstCells.Slice((int)cell_offset, (int)cell_count); Span <uint> src = outlines[i].cells; src.CopyTo(dst); } // memcpy(dstPoints + point_offset, o->points, sizeof(vec2) * o->num_of_points); { var num_of_points = (int)outlines[i].num_of_points; var dst = dstPoints.Slice((int)point_offset, num_of_points); for (var j = 0; j < num_of_points; j += 1) { dst[j] = outlines[i].points[j]; } } point_offset += outlines[i].num_of_points; cell_offset += cell_count; } Debug.Assert(point_offset == total_points); Debug.Assert(cell_offset == total_cells); for (uint i = 0; i < NUMBER_OF_GLYPHS; i++) { outlines[i].fd_outline_destroy(); } FT_CHECK(face.DoneFace()); return(result); }
/// <summary> /// Creates a new <see cref="Fixed26Dot6"/> from a <see cref="System.Decimal"/>. /// </summary> /// <param name="form">A <see cref="LongForm"/> form </param>/// /// <param name="value">A floating-point value.</param> /// <returns>A fixed 26.6 value.</returns> public static Fixed26Dot6 FromDecimal(this LongForm form, decimal value) { return(new Fixed26Dot6(form, value)); }
/// <summary> /// Creates a new <see cref="Fixed26Dot6"/> from a <see cref="System.Double"/>. /// </summary> /// <param name="form">A <see cref="LongForm"/> form </param>/// /// /// <param name="value">A floating-point value.</param> /// <returns>A fixed 26.6 value.</returns> public static Fixed26Dot6 FromDouble(this LongForm form, double value) { return(new Fixed26Dot6(form, value)); }
/// <summary> /// Creates a new <see cref="Fixed26Dot6"/> from <see cref="System.Single"/>. /// </summary> /// <param name="form">A <see cref="LongForm"/> form </param>/// /// /// <param name="value">A floating-point value.</param> /// <returns>A fixed 26.6 value.</returns> public static Fixed26Dot6 FromSingle(this LongForm form, float value) { return(new Fixed26Dot6(form, value)); }
/// <summary> /// Creates a new <see cref="Fixed26Dot6"/> from a <see cref="System.Int32"/> /// </summary> /// <param name="form">A <see cref="LongForm"/> form </param>/// /// <param name="value">A <see cref="System.Int32"/> value.</param> /// <returns>The equivalent <see cref="Fixed26Dot6"/> value.</returns> public static Fixed26Dot6 FromInt32(this LongForm form, int value) { return(new Fixed26Dot6(form, value)); }