のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

widthForGlyph>platformWidthForGlyph

     /external/webkit/Source/WebCore/platform/graphics/SimpleFontData.cpp"
     50 SimpleFontData::SimpleFontData(const FontPlatformData& platformData,
                                      bool isCustomFont, bool isLoading,
                                      bool isTextOrientationFallback)
     51     : m_maxCharWidth(-1)
     52     , m_avgCharWidth(-1)
     53     , m_platformData(platformData)
     54     , m_treatAsFixedPitch(false)
     55     , m_isCustomFont(isCustomFont)
     56     , m_isLoading(isLoading)
     57     , m_isTextOrientationFallback(isTextOrientationFallback)
     58     , m_isBrokenIdeographFallback(false)
     59     , m_hasVerticalGlyphs(false)
     60 {
     61     platformInit();
     62     platformGlyphInit();
     63     platformCharWidthInit(); <==========
     64 }
     /external/webkit/Source/WebCore/platform/graphics/android/fonts/FontDataAndroid.cpp
     77 void SimpleFontData::platformCharWidthInit()
     78 {
     79     m_avgCharWidth = 0.f;
     80     m_maxCharWidth = 0.f;
     81     initCharWidths(); <==========
     82 }
    /external/webkit/Source/WebCore/platform/graphics/SimpleFontData.cpp
    127 void SimpleFontData::initCharWidths()
    128 {
    129     GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page();
    130 
    131     // Treat the width of a '0' as the avgCharWidth.
    132     if (m_avgCharWidth <= 0.f && glyphPageZero) {
    133         static const UChar32 digitZeroChar = '0';
    134         Glyph digitZeroGlyph = glyphPageZero->glyphDataForCharacter(digitZeroChar).glyph;
    135         if (digitZeroGlyph)
    136             m_avgCharWidth = widthForGlyph(digitZeroGlyph); <==========================
    137     }
    138 
    139     // If we can't retrieve the width of a '0', fall back to the x height.
    140     if (m_avgCharWidth <= 0.f)
    141         m_avgCharWidth = m_fontMetrics.xHeight();
    142 
    143     if (m_maxCharWidth <= 0.f)
    144         m_maxCharWidth = max(m_avgCharWidth, m_fontMetrics.floatAscent());
    145 }
    147 void SimpleFontData::platformGlyphInit()
    148 {
    149     GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page();
    150     if (!glyphPageZero) {
    151         LOG_ERROR("Failed to get glyph page zero.");
    152         m_spaceGlyph = 0;
    153         m_spaceWidth = 0;
    154         determinePitch();
    155         m_zeroWidthSpaceGlyph = 0;
    156         m_missingGlyphData.fontData = this;
    157         m_missingGlyphData.glyph = 0;
    158         return;
    159     }
    160 
    161     m_zeroWidthSpaceGlyph = glyphPageZero->glyphDataForCharacter(0).glyph;
    162 
    163     // Nasty hack to determine if we should round or ceil space widths.
    164     // If the font is monospace or fake monospace we ceil to ensure that
    165     // every character and the space are the same width.  Otherwise we round.
    166     m_spaceGlyph = glyphPageZero->glyphDataForCharacter(' ').glyph;
    167     float width = widthForGlyph(m_spaceGlyph); <=======================================
    168     m_spaceWidth = width;
    169     determinePitch();
    170 
    171     // Force the glyph for ZERO WIDTH SPACE to have zero width, unless it is shared with SPACE.
    172     // Helvetica is an example of a non-zero width ZERO WIDTH SPACE glyph.
    173     // See <http://bugs.webkit.org/show_bug.cgi?id=13178>
    174     // Ask for the glyph for 0 to avoid paging in ZERO WIDTH SPACE. Control characters, including 0,
    175     // are mapped to the ZERO WIDTH SPACE glyph.
    176     if (m_zeroWidthSpaceGlyph == m_spaceGlyph) {
    177         m_zeroWidthSpaceGlyph = 0;
    178         LOG_ERROR("Font maps SPACE and ZERO WIDTH SPACE to the same glyph. Glyph width will not be overridden.");
    179     }
    180 
    181     m_missingGlyphData.fontData = this;
    182     m_missingGlyphData.glyph = 0;
    183 }
    310 ALWAYS_INLINE float SimpleFontData::widthForGlyph(Glyph glyph) const
    311 {
    312     if (isZeroWidthSpaceGlyph(glyph))
    313         return 0;
    314 
    315     float width = m_glyphToWidthMap.metricsForGlyph(glyph);
    316     if (width != cGlyphSizeUnknown)
    317         return width;
    318 
    319     width = platformWidthForGlyph(glyph);
    320     m_glyphToWidthMap.setMetricsForGlyph(glyph, width);
    321     return width;
    322 }
||<  
></blockquote><

><blockquote cite="http://tools.oesf.biz/android-4.2.0_r1.0/xref/external/webkit/Source/WebCore/platform/graphics/android/fonts/FontDataAndroid.cpp#127" title="Cross Reference: /external/webkit/Source/WebCore/platform/graphics/android/fonts/FontDataAndroid.cpp"><
Glyphの型はなんだろう?
>|cpp|
    127 float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
    128 {
    129     SkASSERT(sizeof(glyph) == 2);   // compile-time assert
    130 
    131     SkPaint  paint;
    132 
    133     m_platformData.setupPaint(&paint);
    134 
    135     float advanceWidth;
    136     if (EmojiFont::IsEmojiGlyph(glyph))
    137         advanceWidth = EmojiFont::GetAdvanceWidth(glyph, paint);
    138     else {
    139         paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
    140         advanceWidth = SkScalarToFloat(paint.measureText(&glyph, 2));
    141     }

            LOGD("FontDataAndroid.cpp::platformWidthForGlyph glyphID=0x%04X advanceWidth=%f",
                  glyph, advanceWidth); <= glyphは文字コードでない。なんだろ?
    142     return advanceWidth;
    143 }
FontDataAndroid.cppのincludeで
#include "config.h"

#include "EmojiFont.h"
#include "Font.h"
#include "FontCache.h"
#include "SimpleFontData.h" <======
#include "FloatRect.h"
#include "FontDescription.h"
#include "SkFontHost.h"
#include "SkPaint.h"
#include "SkTypeface.h"
#include "SkTime.h"
#ifndef SimpleFontData_h
#define SimpleFontData_h

#include "FontBaseline.h"
#include "FontData.h"
#include "FontMetrics.h"
#include "FontPlatformData.h"
#include "FloatRect.h"
#include "GlyphMetricsMap.h" <===== この中でGlyphが定義される。
#include "GlyphPageTreeNode.h"
#include "TypesettingFeatures.h"
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
 /external/webkit/Source/WebCore/platform/graphics/GlyphMetricsMap.h
 Glyphの定義はこれかな?
39 typedef unsigned short Glyph;