static boolean same_font_name (integer id, integer t) { int ret = 0; if (font_name(t) == NULL || font_name(id) == NULL || strcmp(font_name(t),font_name(id))!=0) { ; } else { ret =1 ; } return ret; }
void CPDF_FormField::LoadDA() { CPDF_Dictionary* pFormDict = m_pForm->m_pFormDict; if (!pFormDict) return; CFX_ByteString DA; if (CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "DA")) DA = pObj->GetString(); if (DA.IsEmpty()) DA = pFormDict->GetStringBy("DA"); if (DA.IsEmpty()) return; CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); if (!pDR) return; CPDF_Dictionary* pFont = pDR->GetDictBy("Font"); if (!pFont) return; CPDF_SimpleParser syntax(DA.AsStringC()); syntax.FindTagParamFromStart("Tf", 2); CFX_ByteString font_name(syntax.GetWord()); CPDF_Dictionary* pFontDict = pFont->GetDictBy(font_name); if (!pFontDict) return; m_pFont = m_pForm->m_pDocument->LoadFont(pFontDict); m_FontSize = FX_atof(syntax.GetWord()); }
void dump_font (int f) { int i,x; set_font_used(f,0); font_tables[f]->charinfo_cache = NULL; dump_things(*(font_tables[f]), 1); dump_string(font_name(f)); dump_string(font_area(f)); dump_string(font_filename(f)); dump_string(font_fullname(f)); dump_string(font_encodingname(f)); dump_string(font_cidregistry(f)); dump_string(font_cidordering(f)); dump_things(*param_base(f),(font_params(f)+1)); if (has_left_boundary(f)) { dump_int(1); dump_charinfo(f,left_boundarychar); } else { dump_int(0); } if (has_right_boundary(f)) { dump_int(1); dump_charinfo(f,right_boundarychar); } else { dump_int(0); } for(i=font_bc(f); i<=font_ec(f); i++) { if (char_exists(f,i)) { dump_charinfo(f,i); } } }
integer copy_font (integer f) { int i; charinfo *ci , *co; integer k = new_font(); memcpy(font_tables[k],font_tables[f],sizeof(texfont)); set_font_cache_id(k,0); set_font_used(k,0); set_font_touched(k,0); font_tables[k]->_font_name = NULL; font_tables[k]->_font_filename = NULL; font_tables[k]->_font_fullname = NULL; font_tables[k]->_font_encodingname = NULL; font_tables[k]->_font_area = NULL; font_tables[k]->_font_cidregistry = NULL; font_tables[k]->_font_cidordering = NULL; font_tables[k]->_left_boundary = NULL; font_tables[k]->_right_boundary = NULL; set_font_name(k,xstrdup(font_name(f))); if (font_filename(f)!= NULL) set_font_filename(k,xstrdup(font_filename(f))); if (font_fullname(f)!= NULL) set_font_fullname(k,xstrdup(font_fullname(f))); if (font_encodingname(f)!= NULL) set_font_encodingname(k,xstrdup(font_encodingname(f))); if (font_area(f)!= NULL) set_font_area(k,xstrdup(font_area(f))); if (font_cidregistry(f)!= NULL) set_font_cidregistry(k,xstrdup(font_cidregistry(f))); if (font_cidordering(f)!= NULL) set_font_cidordering(k,xstrdup(font_cidordering(f))); i = sizeof(*param_base(f))*font_params(f); font_bytes += i; param_base(k) = xmalloc (i); memcpy(param_base(k),param_base(f), i); i = sizeof(charinfo)*(Charinfo_size(f)+1); font_bytes += i; font_tables[k]->charinfo = xmalloc(i); memset(font_tables[k]->charinfo,0,i); for(i=0;i<=Charinfo_size(k);i++) { ci = copy_charinfo(&font_tables[f]->charinfo[i]); font_tables[k]->charinfo[i] = *ci; } if (left_boundary(f)!= NULL ) { ci = copy_charinfo(left_boundary(f)); set_charinfo(k,left_boundarychar,ci); } if (right_boundary(f)!= NULL ) { ci = copy_charinfo(right_boundary(f)); set_charinfo(k,right_boundarychar,ci); } return k; }
std::string OXML_FontManager::getValidFont(OXML_FontLevel level, OXML_CharRange range) { UT_return_val_if_fail( UNKNOWN_LEVEL != level && UNKNOWN_RANGE != range, m_defaultFont); //Algorithm: // 1) Retrieve the lang code mapped with this level/range combination in the Doc Settings std::string script(""), font_name(""); OXML_RangeToScriptMap::iterator it; if (level == MAJOR_FONT) { it = m_major_rts.find(range); if (it == m_major_rts.end()) { switch (range) { // 1a) If no mapping exists, then Ascii/HAnsi = "latin"; EastAsia = "ea"; Complex = "cs" case (ASCII_RANGE): //fallthrough to HANSI_RANGE case (HANSI_RANGE): script = "latin"; break; case (COMPLEX_RANGE): script = "cs"; break; case (EASTASIAN_RANGE): script = "ea"; break; default: UT_ASSERT(UT_SHOULD_NOT_HAPPEN); } } else { script = it->second; } } else { it = m_minor_rts.find(range); if (it == m_minor_rts.end()) { switch (range) { // 1a) If no mapping exists, then Ascii/HAnsi = "latin"; EastAsia = "ea"; Complex = "cs" case (ASCII_RANGE): //fallthrough to HANSI_RANGE case (HANSI_RANGE): script = "latin"; break; case (COMPLEX_RANGE): script = "cs"; break; case (EASTASIAN_RANGE): script = "ea"; break; default: UT_ASSERT(UT_SHOULD_NOT_HAPPEN); } } else { script = it->second; } } // 2) Retrieve the font name mapped with this country string in the Theme OXML_Document * doc = OXML_Document::getInstance(); if (NULL == doc) return m_defaultFont; OXML_SharedTheme theme = doc->getTheme(); if (theme.get() == NULL) return m_defaultFont; if (level == MAJOR_FONT) font_name = theme->getMajorFont(script); else font_name = theme->getMinorFont(script); // 2a) If no mapping exists, return the return default document font if (!font_name.compare("")) return m_defaultFont; // 3) Return getValidFont(font name) return getValidFont(font_name); }
int GetFontSize() const { gint font_size; PangoFontDescription* desc; glib::String font_name(g_settings_get_string(gnome_ui_settings_, GNOME_FONT_NAME.c_str())); desc = pango_font_description_from_string(font_name); font_size = pango_font_description_get_size(desc); pango_font_description_free(desc); return font_size / 1024; }
TE_Editor::TE_Editor(Style* s, TE_View* te_view, int r, int c, int t, int h) : TextEditor(r, c, t, h) { te_view_ = te_view; style_ = s; Resource::ref(style_); // init font to be used inside editor String font_name("fixed"); style_->find_attribute("textFont", font_name); font_ = Font::lookup(font_name); Resource::ref(font_); }
/* return 1 == identical */ boolean cmp_font_name (integer id, strnumber t) { char *tid , *tt; if (!is_valid_font(id)) return 0; tt = makecstring(t); tid = font_name(id); if (tt == NULL && tid == NULL) return 1; if (tt == NULL || tid == NULL || strcmp(tid,tt)!=0) return 0; return 1; }
WT_Boolean WT_Font::operator== (WT_Attribute const & attrib) const { if (attrib.object_id() == Font_ID && style() == ((WT_Font const &)attrib).style() && charset() == ((WT_Font const &)attrib).charset() && pitch() == ((WT_Font const &)attrib).pitch() && family() == ((WT_Font const &)attrib).family() && font_name() == ((WT_Font const &)attrib).font_name() && height() == ((WT_Font const &)attrib).height() && rotation() == ((WT_Font const &)attrib).rotation() && width_scale() == ((WT_Font const &)attrib).width_scale() && spacing() == ((WT_Font const &)attrib).spacing() && oblique() == ((WT_Font const &)attrib).oblique() && flags() == ((WT_Font const &)attrib).flags() ) return WD_True; else return WD_False; }
static fm_entry_ptr fmlookup(internalfontnumber f) { char *tfm; fm_entry *fm; fm_entry tmp; if (tfm_tree == NULL) fm_read_info(); /* only to read default map file */ tfm = font_name(f); assert(strcmp(tfm, nontfm)); /* Look up for full <tfmname>[+-]<expand> */ tmp.tfm_name = tfm; fm = (fm_entry *) avl_find(tfm_tree, &tmp); if (fm != NULL) { fm->in_use = true; return (fm_entry_ptr) fm; } return (fm_entry_ptr) dummy_fm_entry(); }
WT_Result WT_Font::sync(WT_File & file) const { WD_Assert( (file.file_mode() == WT_File::File_Write) || (file.file_mode() == WT_File::Block_Append) || (file.file_mode() == WT_File::Block_Write)); if (*this != file.rendition().font()) { // Find out which fields of the font definition have changed and only // output those sub-fields. ((WT_Font &)(*this)).m_fields_defined = 0; if (font_name() != file.rendition().font().font_name()) ((WT_Font &)(*this)).m_fields_defined |= FONT_NAME_BIT; if (charset() != file.rendition().font().charset()) ((WT_Font &)(*this)).m_fields_defined |= FONT_CHARSET_BIT; if (pitch() != file.rendition().font().pitch()) ((WT_Font &)(*this)).m_fields_defined |= FONT_PITCH_BIT; if (family() != file.rendition().font().family()) ((WT_Font &)(*this)).m_fields_defined |= FONT_FAMILY_BIT; if (style() != file.rendition().font().style()) ((WT_Font &)(*this)).m_fields_defined |= FONT_STYLE_BIT; if (height() != file.rendition().font().height()) ((WT_Font &)(*this)).m_fields_defined |= FONT_HEIGHT_BIT; if (width_scale() != file.rendition().font().width_scale()) ((WT_Font &)(*this)).m_fields_defined |= FONT_WIDTH_SCALE_BIT; if (spacing() != file.rendition().font().spacing()) ((WT_Font &)(*this)).m_fields_defined |= FONT_SPACING_BIT; if (oblique() != file.rendition().font().oblique()) ((WT_Font &)(*this)).m_fields_defined |= FONT_OBLIQUE_BIT; if (flags() != file.rendition().font().flags()) ((WT_Font &)(*this)).m_fields_defined |= FONT_FLAGS_BIT; if (rotation() != file.rendition().font().rotation()) ((WT_Font &)(*this)).m_fields_defined |= FONT_ROTATION_BIT; WD_CHECK (serialize(file)); file.rendition().font() = *this; } return WT_Result::Success; }
CDebugger::CDebugger(CDisplay& Display, CSettingsManager& Settings): Display(Display) { /* Load the main font to be used throughout * the debugger information. */ std::string font_name(Settings.GetValueAt("DebugFont")); if(font_name == "") /* Erroneous font name, hopefully we can * load a safe alternative. */ font_name == "C:\\Windows\\Fonts\\Arial.ttf"; std::string size(Settings.GetValueAt("DebugFontSize")); if(size == "") /* No font size given! Most likely the font name * check failed as well, so a 12pt Arial font * would be just fine for debug info. */ size = "12"; this->debug_font = TTF_OpenFont(font_name.c_str(), atoi(size.c_str())); if(!this->debug_font) handleError(TTF_GetError()); /* For debug builds of the program, * debugging is automatically on by default. */ #ifdef _DEBUG this->ToggleDebugMode(true); #else this->ToggleDebugMode(false); #endif // _DEBUG }
static void dump_runs (PangoLayout *layout, GString *string) { PangoLayoutIter *iter; PangoLayoutRun *run; PangoItem *item; const gchar *text; gint index, index2; gboolean has_more; gchar *char_str; gint i; gchar *font; text = pango_layout_get_text (layout); iter = pango_layout_get_iter (layout); has_more = TRUE; index = pango_layout_iter_get_index (iter); i = 0; while (has_more) { run = pango_layout_iter_get_run (iter); has_more = pango_layout_iter_next_run (iter); i++; if (has_more) { index2 = pango_layout_iter_get_index (iter); char_str = g_strndup (text + index, index2 - index); } else { char_str = g_strdup (text + index); } if (run) { item = ((PangoGlyphItem*)run)->item; font = font_name (item->analysis.font); g_string_append_printf (string, "i=%d, index=%d, chars=%d, level=%d, gravity=%s, flags=%d, font=%s, script=%s, language=%s, '%s'\n", i, index, item->num_chars, item->analysis.level, gravity_name (item->analysis.gravity), item->analysis.flags, "OMITTED", /* for some reason, this fails on build.gnome.org, so leave it out */ script_name (item->analysis.script), pango_language_to_string (item->analysis.language), char_str); dump_extra_attrs (item->analysis.extra_attrs, string); g_free (font); } else { g_string_append_printf (string, "i=%d, index=%d, no run, line end\n", i, index); } g_free (char_str); index = index2; } pango_layout_iter_free (iter); }
static int do_define_font (integer f, char *cnom, char *caire, scaled s, integer natural_dir) { boolean res; /* was the callback successful? */ integer callback_id; char *cnam; #if TIMERS struct timeval tva; struct timeval tvb; double tvdiff; #endif int r; res = 0; callback_id=callback_defined(define_font_callback); if (callback_id>0) { if (caire == NULL || strlen(caire)==0) { cnam = xstrdup(cnom); } else { cnam = xmalloc(strlen(cnom)+strlen(caire)+2); sprintf(cnam,"%s/%s",caire,cnom); } #if TIMERS gettimeofday(&tva,NULL); #endif callback_id = run_and_save_callback(callback_id,"Sdd->",cnam,s,f); #if TIMERS gettimeofday(&tvb,NULL); tvdiff = tvb.tv_sec*1000000.0; tvdiff += (double)tvb.tv_usec; tvdiff -= (tva.tv_sec*1000000.0); tvdiff -= (double)tva.tv_usec; tvdiff /= 1000000; fprintf(stdout,"\ncallback('define_font',%s,%i): %f seconds\n", cnam,f,tvdiff); #endif free(cnam); if (callback_id>0) { /* success */ luaL_checkstack(Luas[0],1,"out of stack space"); lua_rawgeti(Luas[0],LUA_REGISTRYINDEX, callback_id); if (lua_istable(Luas[0],-1)) { #if TIMERS gettimeofday(&tva,NULL); #endif res = font_from_lua(Luas[0],f); destroy_saved_callback (callback_id); #if TIMERS gettimeofday(&tvb,NULL); tvdiff = tvb.tv_sec*1000000.0; tvdiff += (double)tvb.tv_usec; tvdiff -= (tva.tv_sec*1000000.0); tvdiff -= (double)tva.tv_usec; tvdiff /= 1000000; fprintf(stdout,"font_from_lua(%s,%i): %f seconds\n", font_name(f),f,tvdiff); #endif lua_pop(Luas[0],1); } else if (lua_isnumber(Luas[0],-1)) { r = lua_tonumber(Luas[0],-1); destroy_saved_callback (callback_id); delete_font(f); lua_pop(Luas[0],1); return r; } else { lua_pop(Luas[0],1); delete_font(f); return 0; } } } else { res = read_tfm_info(f,cnom,caire,s); if (res) { set_hyphen_char(f,get_default_hyphen_char()); set_skew_char(f,get_default_skew_char()); } } if (res) { do_vf(f); set_font_natural_dir(f,natural_dir); return f; } else { delete_font(f); return 0; } }
WT_Result WT_Font::serialize(WT_File & file) const { WD_CHECK (file.dump_delayed_drawable()); file.desired_rendition().blockref(); WD_CHECK(file.desired_rendition().sync(file, WT_Rendition::BlockRef_Bit)); file.desired_rendition().font_extension(); WD_CHECK(file.desired_rendition().sync(file, WT_Rendition::Font_Extension_Bit)); // BPM: this could be improved when time allows... if(file.heuristics().apply_transform() && !m_rotation_checked && file.heuristics().transform().rotation()) { // The first time we start up the file, if the application wants an unrotated // font, and we need to flip landscape to portrait, then the above test will think // that the rotation doesn't need to be output the first time. Here we force it... ((WT_Font &)(*this)).m_fields_defined |= FONT_ROTATION_BIT; ((WT_Font *)this)->m_rotation_checked = WD_True; // Cast from const to alterable. } if (file.heuristics().allow_binary_data()) { // Binary WD_CHECK (file.write((WT_Byte) 0x06)); // CTRL-F WD_CHECK (file.write(m_fields_defined)); } else { // ASCII Output WD_CHECK (file.write_tab_level()); WD_CHECK (file.write("(Font")); } if (m_fields_defined & FONT_NAME_BIT) WD_CHECK (font_name().serialize(*this, file)); if (m_fields_defined & FONT_CHARSET_BIT) WD_CHECK (charset().serialize(*this, file)); if (m_fields_defined & FONT_PITCH_BIT) WD_CHECK (pitch().serialize(*this, file)); if (m_fields_defined & FONT_FAMILY_BIT) WD_CHECK (family().serialize(*this, file)); if (m_fields_defined & (FONT_STYLE_BIT)) WD_CHECK (style().serialize(*this, file)); if (m_fields_defined & FONT_HEIGHT_BIT) WD_CHECK (height().serialize(*this,file)); if (m_fields_defined & FONT_ROTATION_BIT) WD_CHECK (rotation().serialize(*this,file)); if (m_fields_defined & FONT_WIDTH_SCALE_BIT) WD_CHECK (width_scale().serialize(*this,file)); if (m_fields_defined & FONT_SPACING_BIT) WD_CHECK (spacing().serialize(*this,file)); if (m_fields_defined & FONT_OBLIQUE_BIT) WD_CHECK (oblique().serialize(*this,file)); if (m_fields_defined & FONT_FLAGS_BIT) WD_CHECK (flags().serialize(*this,file)); if (!file.heuristics().allow_binary_data()) WD_CHECK (file.write((WT_Byte)')')); return WT_Result::Success; }
// Render void CProfileViewer::RenderProfile() { if (!m->profileVisible) return; if (!m->path.size()) { m->profileVisible = false; return; } PROFILE3_GPU("profile viewer"); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); AbstractProfileTable* table = m->path[m->path.size() - 1]; const std::vector<ProfileColumn>& columns = table->GetColumns(); size_t numrows = table->GetNumberRows(); CStrIntern font_name("mono-stroke-10"); CFontMetrics font(font_name); int lineSpacing = font.GetLineSpacing(); // Render background GLint estimate_height; GLint estimate_width; estimate_width = 50; for(size_t i = 0; i < columns.size(); ++i) estimate_width += (GLint)columns[i].width; estimate_height = 3 + (GLint)numrows; if (m->path.size() > 1) estimate_height += 2; estimate_height = lineSpacing*estimate_height; CShaderTechniquePtr solidTech = g_Renderer.GetShaderManager().LoadEffect(str_gui_solid); solidTech->BeginPass(); CShaderProgramPtr solidShader = solidTech->GetShader(); solidShader->Uniform(str_color, 0.0f, 0.0f, 0.0f, 0.5f); CMatrix3D transform = GetDefaultGuiMatrix(); solidShader->Uniform(str_transform, transform); float backgroundVerts[] = { (float)estimate_width, 0.0f, 0.0f, 0.0f, 0.0f, (float)estimate_height, 0.0f, (float)estimate_height, (float)estimate_width, (float)estimate_height, (float)estimate_width, 0.0f }; solidShader->VertexPointer(2, GL_FLOAT, 0, backgroundVerts); solidShader->AssertPointersBound(); glDrawArrays(GL_TRIANGLES, 0, 6); transform.PostTranslate(22.0f, lineSpacing*3.0f, 0.0f); solidShader->Uniform(str_transform, transform); // Draw row backgrounds for (size_t row = 0; row < numrows; ++row) { if (row % 2) solidShader->Uniform(str_color, 1.0f, 1.0f, 1.0f, 0.1f); else solidShader->Uniform(str_color, 0.0f, 0.0f, 0.0f, 0.1f); float rowVerts[] = { -22.f, 2.f, estimate_width-22.f, 2.f, estimate_width-22.f, 2.f-lineSpacing, estimate_width-22.f, 2.f-lineSpacing, -22.f, 2.f-lineSpacing, -22.f, 2.f }; solidShader->VertexPointer(2, GL_FLOAT, 0, rowVerts); solidShader->AssertPointersBound(); glDrawArrays(GL_TRIANGLES, 0, 6); transform.PostTranslate(0.0f, lineSpacing, 0.0f); solidShader->Uniform(str_transform, transform); } solidTech->EndPass(); // Print table and column titles CShaderTechniquePtr textTech = g_Renderer.GetShaderManager().LoadEffect(str_gui_text); textTech->BeginPass(); CTextRenderer textRenderer(textTech->GetShader()); textRenderer.Font(font_name); textRenderer.Color(1.0f, 1.0f, 1.0f); textRenderer.PrintfAt(2.0f, lineSpacing, L"%hs", table->GetTitle().c_str()); textRenderer.Translate(22.0f, lineSpacing*2.0f, 0.0f); float colX = 0.0f; for (size_t col = 0; col < columns.size(); ++col) { CStrW text = columns[col].title.FromUTF8(); int w, h; font.CalculateStringSize(text.c_str(), w, h); float x = colX; if (col > 0) // right-align all but the first column x += columns[col].width - w; textRenderer.Put(x, 0.0f, text.c_str()); colX += columns[col].width; } textRenderer.Translate(0.0f, lineSpacing, 0.0f); // Print rows int currentExpandId = 1; for (size_t row = 0; row < numrows; ++row) { if (table->IsHighlightRow(row)) textRenderer.Color(1.0f, 0.5f, 0.5f); else textRenderer.Color(1.0f, 1.0f, 1.0f); if (table->GetChild(row)) { textRenderer.PrintfAt(-15.0f, 0.0f, L"%d", currentExpandId); currentExpandId++; } float colX = 0.0f; for (size_t col = 0; col < columns.size(); ++col) { CStrW text = table->GetCellText(row, col).FromUTF8(); int w, h; font.CalculateStringSize(text.c_str(), w, h); float x = colX; if (col > 0) // right-align all but the first column x += columns[col].width - w; textRenderer.Put(x, 0.0f, text.c_str()); colX += columns[col].width; } textRenderer.Translate(0.0f, lineSpacing, 0.0f); } textRenderer.Color(1.0f, 1.0f, 1.0f); if (m->path.size() > 1) { textRenderer.Translate(0.0f, lineSpacing, 0.0f); textRenderer.Put(-15.0f, 0.0f, L"0"); textRenderer.Put(0.0f, 0.0f, L"back to parent"); } textRenderer.Render(); textTech->EndPass(); glDisable(GL_BLEND); glEnable(GL_DEPTH_TEST); }
font_face_cache_key font_face_cache::make_face_key(const face_ptr font_face, double size) { std::string font_name ( font_face->get_face()->family_name); font_name.append(font_face->get_face()->style_name); return std::make_pair(font_name, size); }
/************************************************************************* SAX2 Handler methods *************************************************************************/ void Font_xmlHandler::elementStart(const String& element, const XMLAttributes& attributes) { // handle a Mapping element if (element == MappingElement) { if (!d_font->d_freetype) { String image_name(attributes.getValueAsString(MappingImageAttribute)); utf32 codepoint = (utf32)attributes.getValueAsInteger(MappingCodepointAttribute); int horzAdvance = attributes.getValueAsInteger(MappingHorzAdvanceAttribute, -1); Font::glyphDat mapDat; mapDat.d_image = &d_font->d_glyph_images->getImage(image_name); // calculate advance width if it was not specified if (horzAdvance == AutoGenerateHorzAdvance) { horzAdvance = (int)(mapDat.d_image->getWidth() + mapDat.d_image->getOffsetX()); } mapDat.d_horz_advance_unscaled = horzAdvance; mapDat.d_horz_advance = (uint)(((float)horzAdvance) * (d_font->d_autoScale ? d_font->d_horzScaling : 1.0f)); d_font->d_cp_map[codepoint] = mapDat; } else { Logger::getSingleton().logEvent((utf8*)"Mapping element encountered. This element is invalid for dynamic fonts.", Informative); } } // handle root Font element else if (element == FontElement) { // get name of font we are creating String font_name(attributes.getValueAsString(FontNameAttribute)); // get filename for the font String filename(attributes.getValueAsString(FontFilenameAttribute)); // get resource group for font file. String resourceGroup(attributes.getValueAsString(FontResourceGroupAttribute)); Logger::getSingleton().logEvent("Started creation of Font '" + font_name + "' via XML file.", Informative); // // load auto-scaling configuration // float hres, vres; bool auto_scale; // get native horizontal resolution hres = (float)attributes.getValueAsInteger(FontNativeHorzResAttribute, 640); // get native vertical resolution vres = (float)attributes.getValueAsInteger(FontNativeVertResAttribute, 480); // get auto-scaling setting auto_scale = attributes.getValueAsBool(FontAutoScaledAttribute, false); // // get type of font // String font_type(attributes.getValueAsString(FontTypeAttribute)); // dynamic (ttf) font if (font_type == FontTypeDynamic) { // get size of font uint size = (uint)attributes.getValueAsInteger(FontSizeAttribute, 12); // extract codepoint range utf32 first_codepoint = (utf32)attributes.getValueAsInteger(FontFirstCodepointAttribute, 32); utf32 last_codepoint = (utf32)attributes.getValueAsInteger(FontLastCodepointAttribute, 127); // build string containing the required code-points. for (; first_codepoint <= last_codepoint; ++first_codepoint) { d_glyphSet += first_codepoint; } uint flags = attributes.getValueAsBool(FontAntiAliasedAttribute, true) ? 0 : NoAntiAlias; // perform pre-initialisation d_font->setNativeResolution(Size(hres, vres)); d_font->setAutoScalingEnabled(auto_scale); // Finalise construction of font without glyphs. // Glyphs will defined after we know which ones we need. d_font->constructor_impl(font_name, filename, resourceGroup, size, flags, String("")); } // static (Imageset based) font else if (font_type == FontTypeStatic) { d_font->d_name = font_name; d_font->d_freetype = false; // load the Imageset d_font->d_glyph_images = ImagesetManager::getSingleton().createImageset(filename, resourceGroup); d_font->setNativeResolution(Size(hres, vres)); d_font->setAutoScalingEnabled(auto_scale); } // error (should never happen) else { throw FileIOException("Font::xmlHandler::startElement - The unknown Font:Type attribute value '" + font_type + "' was encountered while processing the Font file."); } d_font->d_sourceFilename = filename; } // Glyph element else if (element == GlyphElement) { if (d_font->d_freetype) { utf32 codepoint = (utf32)attributes.getValueAsInteger(GlyphCodepointAttribute); if (d_glyphSet.find(codepoint) == String::npos) { d_glyphSet.append(1, codepoint); } } else { Logger::getSingleton().logEvent((utf8*)"Glyph element encountered. This element is invalid for static fonts.", Informative); } } // GlyphRange element else if (element == GlyphRangeElement) { if (d_font->d_freetype) { utf32 start = (utf32)attributes.getValueAsInteger(GlyphRangeStartCodepointAttribute); utf32 end = (utf32)attributes.getValueAsInteger(GlyphRangeEndCodepointAttribute); for (utf32 codepoint = start; codepoint <= end; ++codepoint) { if (d_glyphSet.find(codepoint) == String::npos) { d_glyphSet.append(1, codepoint); } } } else { Logger::getSingleton().logEvent((utf8*)"GlyphRange element encountered. This element is invalid for static fonts.", Informative); } } // GlyphSet element else if (element == GlyphSetElement) { if (d_font->d_freetype) { String glyphs(attributes.getValueAsString(GlyphSetGlyphsAttribute)); for (String::size_type i = 0; i < glyphs.length(); ++i) { utf32 codepoint = glyphs[i]; if (d_glyphSet.find(codepoint) == String::npos) { d_glyphSet.append(1, codepoint); } } } else { Logger::getSingleton().logEvent((utf8*)"GlyphSet element encountered. This element is invalid for static fonts.", Informative); } } // anything else is an error which *should* have already been caught by XML validation else { throw FileIOException("Font::xmlHandler::startElement - Unexpected data was found while parsing the Font file: '" + element + "' is unknown."); } }
void lbp_printer::set_char(int idx, font *f, const environment *env, int w, const char *) { int code = f->get_code(idx); unsigned char ch = code & 0xff; unsigned short symbol_set = code >> 8; if (f != cur_font) { lbp_font *psf = (lbp_font *)f; // fprintf(stderr, "Loading font %s \"%d\" \n", psf->lbpname, env->size); if (psf->is_scalable) { // Scalable font selection is different from bitmaped lbpprintf("\033Pz%s.IBML\033\\\033[%d C", psf->lbpname, (int)((env->size * font::res) / 72)); } else // bitmapped font lbpprintf("\033Pz%s.IBML\033\\\n", font_name(psf, env->size)); lbpputs("\033)' 1"); // Select IBML and IBMR1 symbol set cur_font = psf; cur_symbol_set = 0; // Update the line thickness if needed if ((req_linethickness < 0 ) && (env->size != cur_size)) set_line_thickness(req_linethickness,env); cur_size = env->size; } if (symbol_set != cur_symbol_set) { if (cur_symbol_set == 3) // if current symbol set is Symbol we must restore the font lbpprintf("\033Pz%s.IBML\033\\\033[%d C", cur_font->lbpname, (int)((env->size * font::res) / 72)); switch (symbol_set) { case 0: lbpputs("\033('$2\033)' 1"); // Select IBML and IBMR1 symbol sets break; case 1: lbpputs("\033(d\033)' 1"); // Select wp54 symbol set break; case 2: lbpputs("\033('$2\033)'!0"); // Select IBMP symbol set break; case 3: lbpprintf("\033PzSymbol.SYML\033\\\033[%d C", (int)((env->size * font::res) / 72)); lbpputs("\033(\"!!0\033)\"!!1"); // Select symbol font break; case 4: lbpputs("\033)\"! 1\033(\"!$2"); // Select PS symbol set break; } cur_symbol_set = symbol_set; } if (env->size != cur_size) { if (!cur_font->is_scalable) lbpprintf("\033Pz%s.IBML\033\\\n", font_name(cur_font, env->size)); else lbpprintf("\033[%d C", (int)((env->size * font::res) / 72)); cur_size = env->size; // Update the line thickness if needed if (req_linethickness < 0 ) set_line_thickness(req_linethickness,env); } if ((env->hpos != cur_hpos) || (env->vpos != cur_vpos)) { // lbpmoveabs(env->hpos - ((5 * 300) / 16), env->vpos); lbpmoveabs(env->hpos - 64, env->vpos - 64); cur_vpos = env->vpos; cur_hpos = env->hpos; } if ((ch & 0x7F) < 32) lbpputs("\033[1.v"); lbpputc(ch); cur_hpos += w; }