Exemplo n.º 1
0
 def get_font_measurements(self,
                           cap_height: float,
                           font=None) -> FontMeasurements:
     return FontMeasurements(baseline=0.0,
                             cap_top=1.0,
                             x_top=0.5,
                             bottom=-0.2)
Exemplo n.º 2
0
 def get_font_measurements(self,
                           cap_height: float,
                           font=None) -> FontMeasurements:
     return FontMeasurements(baseline=0.0,
                             cap_height=1.0,
                             x_height=0.5,
                             descender_height=0.2)
Exemplo n.º 3
0
def _get_font_measurements(font: FontProperties = FontProperties()
                           ) -> "FontMeasurements":
    upper_x = _text_path('X', font).vertices[:, 1].tolist()
    lower_x = _text_path('x', font).vertices[:, 1].tolist()
    lower_p = _text_path('p', font).vertices[:, 1].tolist()
    return FontMeasurements(baseline=min(lower_x),
                            cap_top=max(upper_x),
                            x_top=max(lower_x),
                            bottom=min(lower_p))
Exemplo n.º 4
0
def _get_font_measurements(font: qg.QFont) -> FontMeasurements:
    upper_x = _get_text_rect(font, 'X')
    lower_x = _get_text_rect(font, 'x')
    lower_p = _get_text_rect(font, 'p')
    return FontMeasurements(
        baseline=lower_x.bottom(),
        cap_top=upper_x.top(),
        x_top=lower_x.top(),
        bottom=lower_p.bottom(),
    )
Exemplo n.º 5
0
 def get_font_measurements(self, font: FontProperties) -> FontMeasurements:
     # None is the default font.
     key = hash(font)
     measurements = self._font_measurement_cache.get(key)
     if measurements is None:
         upper_x = self.get_text_path('X', font).vertices[:, 1].tolist()
         lower_x = self.get_text_path('x', font).vertices[:, 1].tolist()
         lower_p = self.get_text_path('p', font).vertices[:, 1].tolist()
         baseline = min(lower_x)
         measurements = FontMeasurements(baseline=baseline,
                                         cap_height=max(upper_x) - baseline,
                                         x_height=max(lower_x) - baseline,
                                         descender_height=baseline -
                                         min(lower_p))
         self._font_measurement_cache[key] = measurements
     return measurements
Exemplo n.º 6
0
 def get_font_measurements(self, font: qg.QFont) -> FontMeasurements:
     # None is the default font.
     key = hash(font)  # good hash?
     measurements = self._font_measurement_cache.get(key)
     if measurements is None:
         upper_x = self.get_text_rect('X', font)
         lower_x = self.get_text_rect('x', font)
         lower_p = self.get_text_rect('p', font)
         baseline = lower_x.bottom()
         measurements = FontMeasurements(
             baseline=baseline,
             cap_height=baseline - upper_x.top(),
             x_height=baseline - lower_x.top(),
             descender_height=lower_p.bottom() - baseline,
         )
         self._font_measurement_cache[key] = measurements
     return measurements