"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Plugins/Freetype/tt_face.cpp" between
TeXmacs-1.99.4-src.tar.gz and TeXmacs-1.99.5-src.tar.gz

About: GNU TeXmacs is a what-you-see-is-what-you-get scientific text editor, which was both inspired by TeX and GNU Emacs.

tt_face.cpp  (TeXmacs-1.99.4-src):tt_face.cpp  (TeXmacs-1.99.5-src)
skipping to change at line 56 skipping to change at line 56
return face; return face;
} }
/****************************************************************************** /******************************************************************************
* Font metrics * Font metrics
******************************************************************************/ ******************************************************************************/
static metric error_metric; static metric error_metric;
tt_font_metric_rep::tt_font_metric_rep ( tt_font_metric_rep::tt_font_metric_rep (
string name, string family, int size2, int dpi2): string name, string family, int size2, int hdpi2, int vdpi2):
font_metric_rep (name), size (size2), dpi (dpi2), fnm (NULL) font_metric_rep (name), size (size2), hdpi (hdpi2), vdpi (vdpi2), fnm (NULL)
{ {
face= load_tt_face (family); face= load_tt_face (family);
bad_font_metric= face->bad_face || bad_font_metric= face->bad_face ||
ft_set_char_size (face->ft_face, 0, size<<6, dpi, dpi); ft_set_char_size (face->ft_face, 0, size<<6, hdpi, vdpi);
if (bad_font_metric) return; if (bad_font_metric) return;
error_metric->x1= error_metric->y1= 0; error_metric->x1= error_metric->y1= 0;
error_metric->x2= error_metric->y2= 0; error_metric->x2= error_metric->y2= 0;
error_metric->x3= error_metric->y3= 0; error_metric->x3= error_metric->y3= 0;
error_metric->x4= error_metric->y4= 0; error_metric->x4= error_metric->y4= 0;
} }
bool bool
tt_font_metric_rep::exists (int i) { tt_font_metric_rep::exists (int i) {
if (face->bad_face) return false; if (face->bad_face) return false;
if (fnm->contains (i)) return true; if (fnm->contains (i)) return true;
FT_UInt glyph_index= ft_get_char_index (face->ft_face, i); FT_UInt glyph_index= ft_get_char_index (face->ft_face, i);
return glyph_index != 0; return glyph_index != 0;
} }
metric& metric&
tt_font_metric_rep::get (int i) { tt_font_metric_rep::get (int i) {
if (!face->bad_face && !fnm->contains(i)) { if (!face->bad_face && !fnm->contains(i)) {
ft_set_char_size (face->ft_face, 0, size<<6, dpi, dpi); ft_set_char_size (face->ft_face, 0, size<<6, hdpi, vdpi);
FT_UInt glyph_index= ft_get_char_index (face->ft_face, i); FT_UInt glyph_index= ft_get_char_index (face->ft_face, i);
if (ft_load_glyph (face->ft_face, glyph_index, FT_LOAD_DEFAULT)) if (ft_load_glyph (face->ft_face, glyph_index, FT_LOAD_DEFAULT))
return error_metric; return error_metric;
FT_GlyphSlot slot= face->ft_face->glyph; FT_GlyphSlot slot= face->ft_face->glyph;
if (ft_render_glyph (slot, ft_render_mode_mono)) return error_metric; if (ft_render_glyph (slot, ft_render_mode_mono)) return error_metric;
metric_struct* M= tm_new<metric_struct> (); metric_struct* M= tm_new<metric_struct> ();
fnm(i)= (pointer) M; fnm(i)= (pointer) M;
int w= slot->bitmap.width; int w= slot->bitmap.width;
int h= slot->bitmap.rows; int h= slot->bitmap.rows;
SI ww= w * PIXEL; SI ww= w * PIXEL;
skipping to change at line 114 skipping to change at line 114
} }
return *((metric*) ((void*) fnm [i])); return *((metric*) ((void*) fnm [i]));
} }
SI SI
tt_font_metric_rep::kerning (int left, int right) { tt_font_metric_rep::kerning (int left, int right) {
if (face->bad_face || !FT_HAS_KERNING (face->ft_face)) return 0; if (face->bad_face || !FT_HAS_KERNING (face->ft_face)) return 0;
FT_Vector k; FT_Vector k;
FT_UInt l= ft_get_char_index (face->ft_face, left); FT_UInt l= ft_get_char_index (face->ft_face, left);
FT_UInt r= ft_get_char_index (face->ft_face, right); FT_UInt r= ft_get_char_index (face->ft_face, right);
ft_set_char_size (face->ft_face, 0, size<<6, dpi, dpi); ft_set_char_size (face->ft_face, 0, size<<6, hdpi, vdpi);
if (ft_get_kerning (face->ft_face, l, r, FT_KERNING_DEFAULT, &k)) return 0; if (ft_get_kerning (face->ft_face, l, r, FT_KERNING_DEFAULT, &k)) return 0;
return tt_si (k.x); return tt_si (k.x);
} }
font_metric font_metric
tt_font_metric (string family, int size, int dpi) { tt_font_metric (string family, int size, int hdpi, int vdpi) {
string name= family * as_string (size) * "@" * as_string (dpi); string name= family * as_string (size) * "@" * as_string (hdpi);
if (vdpi != hdpi) name << "x" << as_string (vdpi);
return make (font_metric, name, return make (font_metric, name,
tm_new<tt_font_metric_rep> (name, family, size, dpi)); tm_new<tt_font_metric_rep> (name, family, size, hdpi, vdpi));
} }
/****************************************************************************** /******************************************************************************
* Font glyphs * Font glyphs
******************************************************************************/ ******************************************************************************/
static glyph error_glyph; static glyph error_glyph;
tt_font_glyphs_rep::tt_font_glyphs_rep ( tt_font_glyphs_rep::tt_font_glyphs_rep (
string name, string family, int size2, int dpi2): string name, string family, int size2, int hdpi2, int vdpi2):
font_glyphs_rep (name), size (size2), dpi (dpi2), fng (glyph ()) font_glyphs_rep (name), size (size2),
hdpi (hdpi2), vdpi (vdpi2), fng (glyph ())
{ {
face= load_tt_face (family); face= load_tt_face (family);
bad_font_glyphs= face->bad_face || bad_font_glyphs= face->bad_face ||
ft_set_char_size (face->ft_face, 0, size<<6, dpi, dpi); ft_set_char_size (face->ft_face, 0, size<<6, hdpi, vdpi);
if (bad_font_glyphs) return; if (bad_font_glyphs) return;
} }
glyph& glyph&
tt_font_glyphs_rep::get (int i) { tt_font_glyphs_rep::get (int i) {
if (!face->bad_face && !fng->contains(i)) { if (!face->bad_face && !fng->contains(i)) {
ft_set_char_size (face->ft_face, 0, size<<6, dpi, dpi); ft_set_char_size (face->ft_face, 0, size<<6, hdpi, vdpi);
FT_UInt glyph_index= ft_get_char_index (face->ft_face, i); FT_UInt glyph_index= ft_get_char_index (face->ft_face, i);
if (ft_load_glyph (face->ft_face, glyph_index, FT_LOAD_DEFAULT)) if (ft_load_glyph (face->ft_face, glyph_index, FT_LOAD_DEFAULT))
return error_glyph; return error_glyph;
FT_GlyphSlot slot= face->ft_face->glyph; FT_GlyphSlot slot= face->ft_face->glyph;
if (ft_render_glyph (slot, ft_render_mode_mono)) return error_glyph; if (ft_render_glyph (slot, ft_render_mode_mono)) return error_glyph;
int w= slot->bitmap.width; int w= slot->bitmap.width;
int h= slot->bitmap.rows; int h= slot->bitmap.rows;
int ox= tt_round (slot->metrics.horiBearingX); int ox= tt_round (slot->metrics.horiBearingX);
int oy= tt_round (slot->metrics.horiBearingY); int oy= tt_round (slot->metrics.horiBearingY);
skipping to change at line 185 skipping to change at line 187
} }
//cout << "Glyph " << i << " of " << res_name << "\n"; //cout << "Glyph " << i << " of " << res_name << "\n";
//cout << G << "\n"; //cout << G << "\n";
if (G->width * G->height == 0) G= error_glyph; if (G->width * G->height == 0) G= error_glyph;
fng(i)= G; fng(i)= G;
} }
return fng(i); return fng(i);
} }
font_glyphs font_glyphs
tt_font_glyphs (string family, int size, int dpi) { tt_font_glyphs (string family, int size, int hdpi, int vdpi) {
string name= string name=
family * ":" * as_string (size) * "." * as_string (dpi) * "tt"; family * ":" * as_string (size) * "." * as_string (hdpi);
if (vdpi != hdpi) name << "x" << as_string (vdpi);
name << "tt";
return make (font_glyphs, name, return make (font_glyphs, name,
tm_new<tt_font_glyphs_rep> (name, family, size, dpi)); tm_new<tt_font_glyphs_rep> (name, family, size, hdpi, vdpi));
} }
#endif // USE_FREETYPE #endif // USE_FREETYPE
 End of changes. 12 change blocks. 
15 lines changed or deleted 19 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS