Merge pull request #10243 from ahocevar/fix-font-measure
Store correct font value
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 7.5 KiB |
@@ -65,6 +65,22 @@ feature.setStyle(new Style({
|
||||
}));
|
||||
vectorSource.addFeature(feature);
|
||||
|
||||
// align left
|
||||
feature = new Feature({
|
||||
geometry: new Point([50, 50])
|
||||
});
|
||||
feature.setStyle(new Style({
|
||||
text: new Text({
|
||||
font: 'Ubuntu',
|
||||
text: 'align left',
|
||||
textAlign: 'left',
|
||||
stroke: new Stroke({
|
||||
color: [10, 10, 10, 0.5]
|
||||
})
|
||||
})
|
||||
}));
|
||||
vectorSource.addFeature(feature);
|
||||
|
||||
// background and padding
|
||||
feature = new Feature({
|
||||
geometry: new Point([-10, 0])
|
||||
|
||||
@@ -333,7 +333,8 @@ export const measureTextHeight = (function() {
|
||||
export function measureTextWidth(font, text) {
|
||||
const measureContext = getMeasureContext();
|
||||
if (font != measureFont) {
|
||||
measureContext.font = measureFont = font;
|
||||
measureContext.font = font;
|
||||
measureFont = measureContext.font;
|
||||
}
|
||||
return measureContext.measureText(text).width;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user