// -*- C++ -*- /* This file is part of * ====================================================== * * LyX, The Document Processor * * Copyright (C) 1997 Asger Alstrup * and the LyX Team. * *======================================================*/ #include #include // fabs() #include // atoi() #ifdef __GNUG__ #pragma implementation "FontInfo.h" #endif #include "FontInfo.h" #include "error.h" #include "lyxrc.h" // lyxrc.use_scalable_fonts extern LyXRC * lyxrc; /// Load font close to this size LString FontInfo::getFontname(int size) { if (!exist()) return LString(); int closestind = -1; double error = 100000; for (int i=0; iuse_scalable_fonts) { // We can use scalable LString font = resize(strings[scaleindex], size); lyxerr.debug("Using scalable font to get\n" + font, Error::FONT); return font; } // Did any fonts get close? if (closestind == -1) { // No, and we are not allowed to use scalables, so... return LString(); } // We use the closest match lyxerr.debug(LString("Using closest font match to get size ") + size + " with\n" + strings[closestind], Error::FONT); return strings[closestind]; } /// Build newly sized font string LString FontInfo::resize(LString const & font, int size) const { // Find the position of the size spec int cut=0, before=0, after=0; for (int i=0; i