CSS Font Advanced
In this page:
selector {
font: style weight size / line-height family;
font-variant: small-caps;
}
font-feature-settings से OpenType Features Unlock करना
कई professional font files optional OpenType features bundle करते हैं -- जैसे stylistic ligatures, old-style figures, या fraction glyphs -- जो default रूप से बंद होते हैं। font-feature-settings आपको किसी specific feature को उसके चार-अक्षर के OpenType tag से चालू करने देता है, जैसे standard ligatures के लिए "liga" या old-style numerals के लिए "onum"।
- पहले font के specimen page या OpenType feature list check करें, क्योंकि font-feature-settings सिर्फ उन tags के लिए काम करता है जिन्हें specific font file असल में implement करती है।
- Accepted values:
- normal — default features (initial value)
- "liga" 0 — एक feature बंद करता है
- "smcp" 1 — small caps चालू करता है
- "tnum" — tabular numbers
- "ss01" — stylistic set 1
- inherit | initial | unset | revert — हर property द्वारा accepted CSS-wide keywords
उदाहरण: Unlocking OpenType Features with font-feature-settings
<style>
p {
font-feature-settings: "liga" 1;
}
</style>
<p>Text with standard ligatures enabled</p>
font-kerning से Letter Spacing Adjust करना
Kerning specific letter pairs (जैसे "A" और "V") के बीच किया गया एक छोटा spacing adjustment है ताकि वे उनकी default character widths की तुलना में visually एक-दूसरे के करीब बैठें। font-kerning: normal इसे explicitly चालू करता है, जबकि font-kerning: none इसे disable कर देता है, हर character को उसकी raw, unadjusted spacing देते हुए।
- लगभग हर case में font-kerning को उसके default auto पर छोड़ें, क्योंकि modern browsers बिना extra configuration के पहले से ही sensibly kerning apply करते हैं।
- Accepted values:
- auto — browser तय करता है (initial value)
- normal — kerning लागू होती है
- none — kerning disabled है
- inherit | initial | unset | revert — हर property द्वारा accepted CSS-wide keywords
उदाहरण: Adjusting Letter Spacing with font-kerning
<style>
.normal { font-kerning: normal; }
.none { font-kerning: none; }
</style>
<p class="normal">AVATAR — kerned</p>
<p class="none">AVATAR — unkerned</p>
font-size-adjust से Fallback Sizes Balance करना
अलग-अलग font families एक ही font-size पर set होने पर भी काफ़ी अलग size के दिख सकते हैं, क्योंकि उनके lowercase letters overall line height का अलग-अलग proportion occupy करते हैं। font-size-adjust आपको एक target aspect ratio specify करने देता है ताकि अगर primary font load न हो और fallback इस्तेमाल हो, तो fallback को automatically resize करके visually match किया जा सके।
- अपने primary font की x-height ratio के आधार पर font-size-adjust set करें ताकि custom font load न होने पर fallback fonts visually consistent रहें।
- Accepted values:
- none — कोई adjustment नहीं (initial value)
- number — aspect value, जैसे 0.5
- from-font — font की अपनी aspect value इस्तेमाल करता है
- inherit | initial | unset | revert — हर property द्वारा accepted CSS-wide keywords
उदाहरण: Balancing Fallback Sizes with font-size-adjust
<style>
p {
font-family: "CustomFont", sans-serif;
font-size-adjust: 0.5;
}
</style>
<p>Fallback font resized to visually match the custom font</p>
font-stretch से Text को Widen और Narrow करना
font-stretch किसी font family का एक condensed या expanded width variant select करता है, बशर्ते font file असल में वे variants ship करती हो (जैसे कई variable fonts अब करती हैं)।
transform: scaleX() के उलट, जो letterforms को squash करके distort करता है, font-stretch genuinely redesigned, narrower या wider glyph shapes swap in करता है।
- font-stretch पर निर्भर होने से पहले check करें कि क्या आपका font एक width axis वाला variable font है, क्योंकि condensed cuts के बिना static fonts इसे बस नज़रअंदाज़ कर देंगे।
- Accepted values:
- normal — standard width (initial value)
- condensed — narrower faces
- expanded — wider faces
- percentage — 50% से 200%
- ultra-condensed / semi-condensed / semi-expanded / ultra-expanded — दूसरे steps
- inherit | initial | unset | revert — हर property द्वारा accepted CSS-wide keywords
उदाहरण: Widening and Narrowing Text with font-stretch
<style>
.condensed {
font-stretch: condensed;
}
.expanded {
font-stretch: expanded;
}
</style>
<p class="condensed">Condensed variant</p>
<p class="expanded">Expanded variant</p>
font-variant-caps से Capital Styles Switch करना
font-variant-caps plain text-transform: uppercase से आगे अलग-अलग capitalization treatments के बीच switch करता है -- small-caps (छोटे capitals की तरह render होने वाले lowercase letters) और all-small-caps (match करने के लिए shrink किए गए uppercase letters) सहित।
अच्छी तरह designed fonts regular capitals को सिर्फ scale down करने के बजाय genuine small-cap glyphs शामिल करते हैं।
- जब आपको classic "small capitals" typographic look चाहिए, full-size capitals नहीं, तो text-transform: uppercase से ज़्यादा font-variant-caps: small-caps prefer करें।
- Accepted values:
- normal — regular capitals (initial value)
- small-caps — lowercase छोटे capitals की तरह दिखाया जाता है
- all-small-caps — सभी letters छोटे capitals की तरह
- petite-caps | all-petite-caps — petite capitals (lowercase के लिए, या सभी letters के लिए)
- unicase | titling-caps — mixed और titling forms
- inherit | initial | unset | revert — हर property द्वारा accepted CSS-wide keywords
उदाहरण: Switching Capital Styles with font-variant-caps
<style>
.small-caps {
font-variant-caps: small-caps;
}
</style>
<p class="small-caps">Small Capitals Look</p>
- यह मान लेना कि font-feature-settings हर font पर काम करता है, जबकि specific OpenType feature इस्तेमाल की जा रही font file में असल में built-in होनी चाहिए।
- font-stretch को transform: scaleX() के साथ confuse करना, जबकि font-stretch सिर्फ तभी काम करता है जब font family genuine condensed या expanded variants ship करती हो।
- font-variant-caps: small-caps इस्तेमाल करना और असली small-caps glyphs की उम्मीद करना, जबकि कई fonts इसके बजाय shrunken regular capitals पर fall back करते हैं।
- font-feature-settings और font-variant-caps ligatures, old-style numerals, और असली small caps जैसे OpenType typographic features unlock करते हैं।
- font-kerning control करता है कि character-pair spacing adjustments (जैसे "A" और "V" के बीच tight fit) लागू होते हैं या नहीं।
- font-stretch और font-size-adjust क्रमशः किसी font की width और fallback sizing behavior fine-tune करते हैं।
font-kerning और font-variant-caps हर modern browser में supported हैं; font-feature-settings और font-stretch को visible effect के लिए loaded font file में relevant OpenType variation data असल में शामिल होना चाहिए।
Chapter Quiz — Complete all 10 topics to unlock
0/10 topics done
Complete these topics first: