133 QFontEngineS60::QFontEngineS60(const QFontDef &request, const QFontEngineS60Extensions *extensions) |
132 QFontEngineS60::QFontEngineS60(const QFontDef &request, const QFontEngineS60Extensions *extensions) |
134 : m_extensions(extensions) |
133 : m_extensions(extensions) |
135 { |
134 { |
136 QFontEngine::fontDef = request; |
135 QFontEngine::fontDef = request; |
137 m_fontSizeInPixels = (request.pixelSize >= 0)? |
136 m_fontSizeInPixels = (request.pixelSize >= 0)? |
138 request.pixelSize:pointsToPixels(request.pointSize); |
137 request.pixelSize:pointsToPixels(request.pointSize); |
139 |
|
140 QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock); |
|
141 |
|
142 m_textRenderBitmap = q_check_ptr(new CFbsBitmap()); // CBase derived object needs check on new |
|
143 const TSize bitmapSize(1, 1); // It is just a dummy bitmap that I need to keep the font alive (or maybe not) |
|
144 qt_symbian_throwIfError(m_textRenderBitmap->Create(bitmapSize, EGray256)); |
|
145 QT_TRAP_THROWING(m_textRenderBitmapDevice = CFbsBitmapDevice::NewL(m_textRenderBitmap)); |
|
146 qt_symbian_throwIfError(m_textRenderBitmapDevice->CreateContext(m_textRenderBitmapGc)); |
|
147 cache_cost = sizeof(QFontEngineS60) + bitmapSize.iHeight * bitmapSize.iWidth * 4; |
|
148 |
138 |
149 TFontSpec fontSpec(qt_QString2TPtrC(request.family), m_fontSizeInPixels); |
139 TFontSpec fontSpec(qt_QString2TPtrC(request.family), m_fontSizeInPixels); |
150 fontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); |
140 fontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); |
151 fontSpec.iFontStyle.SetPosture(request.style == QFont::StyleNormal?EPostureUpright:EPostureItalic); |
141 fontSpec.iFontStyle.SetPosture(request.style == QFont::StyleNormal?EPostureUpright:EPostureItalic); |
152 fontSpec.iFontStyle.SetStrokeWeight(request.weight > QFont::Normal?EStrokeWeightBold:EStrokeWeightNormal); |
142 fontSpec.iFontStyle.SetStrokeWeight(request.weight > QFont::Normal?EStrokeWeightBold:EStrokeWeightNormal); |
153 const TInt errorCode = m_textRenderBitmapDevice->GetNearestFontInPixels(m_font, fontSpec); |
143 const TInt errorCode = S60->screenDevice()->GetNearestFontToDesignHeightInPixels(m_font, fontSpec); |
154 Q_ASSERT(errorCode == 0); |
144 Q_ASSERT(errorCode == 0); |
155 m_textRenderBitmapGc->UseFont(m_font); |
145 |
156 |
146 cache_cost = sizeof(QFontEngineS60); |
157 lock.relock(); |
|
158 } |
147 } |
159 |
148 |
160 QFontEngineS60::~QFontEngineS60() |
149 QFontEngineS60::~QFontEngineS60() |
161 { |
150 { |
162 QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock); |
151 S60->screenDevice()->ReleaseFont(m_font); |
163 |
|
164 m_textRenderBitmapGc->DiscardFont(); |
|
165 delete m_textRenderBitmapGc; |
|
166 m_textRenderBitmapGc = NULL; |
|
167 m_textRenderBitmapDevice->ReleaseFont(m_font); |
|
168 delete m_textRenderBitmapDevice; |
|
169 m_textRenderBitmapDevice = NULL; |
|
170 delete m_textRenderBitmap; |
|
171 m_textRenderBitmap = NULL; |
|
172 |
|
173 lock.relock(); |
|
174 } |
152 } |
175 |
153 |
176 bool QFontEngineS60::stringToCMap(const QChar *characters, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const |
154 bool QFontEngineS60::stringToCMap(const QChar *characters, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const |
177 { |
155 { |
178 if (*nglyphs < len) { |
156 if (*nglyphs < len) { |