About
RT Define Stroke Width
Provides service that might calculate stroke width with specific CSS rules applied.
Usage
Add RtDefineStrokeWidthModule
in imports into your module
:
import {RtDefineStrokeWidthModule} from 'rt-define-stroke-width';
@NgModule({
...
imports: [
...
RtDefineStrokeWidthModule,
...
],
...
})
export class YourModule {
}
Add RtDefineStrokeWidthService
into constructor in your component and call getTextWidth
method when needed.
Api
Service API:
-
getTextWidth
- Defines width for stroke with specific CSS rules.
Example
Simple usage:
constructor(private defineStrokeWidth: RtDefineStrokeWidthService) {
this.strokeWidth = this.defineStrokeWidth.getTextWidth('text', 'font-size: 12px; font-family: Arial, sans-serif;');
}