Mercurial > projects > mde
diff mde/resource/font.d @ 45:0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Moved the implementable widgets from mde.gui.widget.Widget to miscWidgets, leaving base widgets in Widget.
Rewrote some of GridLayoutWidget's implementation. Made many operations general to work for either columns or rows. Some optimisations were intended but ended up being removed due to problems.
Allowed layout's to resize from either direction (only with window resizes).
committer: Diggory Hardy <diggory.hardy@gmail.com>
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Thu, 22 May 2008 11:34:09 +0100 |
parents | 07bd1a09e161 |
children | a98ffb64f066 |
line wrap: on
line diff
--- a/mde/resource/font.d Fri May 16 12:22:10 2008 +0100 +++ b/mde/resource/font.d Thu May 22 11:34:09 2008 +0100 @@ -31,7 +31,9 @@ /** Font class. * - * Particular to a font and size. (Maybe not size?) */ + * Particular to a font and size. (Maybe not size?) + * + * Note: it is not currently intended to be thread-safe. */ class Font { //BEGIN Static: manager @@ -77,7 +79,7 @@ if (FT_New_Face (library, toStringz(path), 0, &face)) throw new fontLoadException ("Unable to read font: "~path); - if (FT_Set_Pixel_Sizes (face, 12,12)) + if (FT_Set_Pixel_Sizes (face, 0,16)) throw new fontLoadException ("Unable to set pixel size"); } @@ -94,9 +96,24 @@ FT_Pos y_adj = 0; // y adjustment (for height) + FT_Bool useKerning = FT_HAS_KERNING (face); + FT_UInt previous = 0; + foreach (chr; str) { + auto gi = FT_Get_Char_Index (face, chr); + + if (useKerning && previous && gi) + { + FT_Vector delta; + + + FT_Get_Kerning (face, previous, gi, FT_Kerning_Mode.FT_KERNING_DEFAULT, &delta); + + pen.x += delta.x; + } + FT_Set_Transform(face, &m, &pen); - if (FT_Load_Char(face, chr, FT_LOAD_RENDER)) + if (FT_Load_Glyph(face, gi, FT_LOAD_RENDER)) return; // give up if (y_adj < g.metrics.height) y_adj = g.metrics.height; @@ -111,11 +128,12 @@ logger.info ("b.pitch != b.width"); //NOTE: y direction! - glRasterPos2i (g.bitmap_left,g.bitmap_top + y_adj/64); + glRasterPos2i (g.bitmap_left,g.bitmap_top /+ (y_adj >> 6)+/); glDrawPixels (b.width, b.rows, GL_LUMINANCE, GL_UNSIGNED_BYTE, cast(void*) b.buffer); pen.x += g.advance.x; pen.y += g.advance.y; + previous = gi; } }