Tải bản đầy đủ - 0 (trang)
Hack 53. Make Your Fonts Pretty

Hack 53. Make Your Fonts Pretty

Tải bản đầy đủ - 0trang

UbuntuusesDefoma,the"DebianFontManager,"tocentralize

andsimplifyfontmanagementacrossallapplications.

Applicationscanvarydramaticallyinhowtheymanagefonts,so

whenanewfontisinstalledonyourcomputer,it'snotalways

obvioushowtotelleachapplicationthatthefontexistsand

wheretofindit.

Defomagetsaroundthisproblembyallowingapplicationsto

registerthemselvesbyprovidingaDefomaconfigurationscript.

Then,whenanewfontisinstalled,Defomaworksthroughall

theconfigurationscriptsandperformswhateveractionis

necessarytoenablethefontforeachapplication.

Thefirstthingyoushoulddothenismakesurethatyour

systemisconfiguredtouseDefomatomanagefonts.Run:

$sudodpkg-reconfiguredefoma





IfDefomaisnotcurrentlysettomanagefonts,youwillbe

askedifyouwanttouseit;answerYes.

Ifyoursystemhasendedupinanuncleanstatewithsome

manuallyinstalledfontsorapplicationsthatcan'tseesome

fonts,youcanforceDefomatototallyrebuilditsconfiguration.

Thisprocessrescansallyourinstalledfontsandmakessureall

registeredapplicationshavebeenupdatedtousethem:

$sudodefoma-reconfigure





OnscreenFont-RenderingPreferences



Variousdisplayshavedifferentcharacteristics,andwhatlooks

goodonaCRTdoesn'tnecessarilylookgoodonanLCD.Ubuntu

providesanumberoffontoptionsthroughSystem

Preferences Font(seeFigure5-7).



Figure5-7.GNOMEFontPreferences



Youcanchangethedefaultsystemfontstosuityour

preferences,butifyouhaveanLCD,theitemtopayattention

toisthesubpixelsmoothingoptionunderFontRendering.Each

pixelinanLCDconsistsofthreesubpixels,oneeachforred,

green,andblue.Subpixelsmoothingtakesthephysicallayout

ofthesubpixelsintoaccounttodisplayfontsassmoothlyas

possible.

Advancedoptions(showninFigure5-8)areaccessiblethrough

theDetailsbuttonnearthebottomright.



Figure5-8.Advancedfontpreferences



Fromhere,youcanspecifyscreenresolution,smoothing,

hinting,andsubpixelorder.



Screenresolution

Whenthefontrendererdisplaystextonscreen,itneedsto

convertbetweenvariousunitstodeterminehowlargethetext

needstobe.Oftenfontsizesarespecifiedaspoints,whichare

unitsofmeasurethathavebeenused(ratherinconsistently!)

forhundredsofyearsbyprinters.Nowadays,mostpeopleagree

ononepointbeingequalto1/72ndofaninch,butifyoutell

yourcomputertodisplay,forexample,18-pointtext,itneeds



toknowtheresolutionofyourdisplaysoitcanfigureouthow

manypixelsareequivalentto18/72nds(i.e.,1/4)ofaninchon

yourparticularscreen.

Screenresolutionisusuallyexpressedasdpi,ordotsperinch.

Tofigureoutthehorizontalandverticalresolutionofyour

screen,measureitswidthandheightandthendividethose

valuesintothepixeldimensionssetinSystem Preferences

ScreenResolution.Forexample,atypicalso-called17-inchLCD

willhavephysicaldimensionsofabout13.3inchesby10.75

inchesandrunatanativeresolutionof1280x1024pixels.That

givesahorizontalresolutionof1280÷13.3=96.2dpi,anda

verticalresolutionof1024÷10.75=95.3dpi.Closeenoughto

callit96dpiforboth.

Bydeterminingtheactualphysicalresolutionofyourdisplay

andsettingthecorrectResolutionvalueintheFontpreferences,

youcanensurethatwhenyourcomputerdisplaysafont

onscreenataspecificsize,itwillbescaledtoappearatthat

actualsize.



Smoothing

TheSmoothingsettingactuallycontrolsthelevelofantialiasing

toapplywhenfontsarerendered.Antialiasingcanhavea

dramaticimpactontheclarityoffonts,particularlywhen

displayedonanLCD.Itsmoothsoutjaggycornersandedges

onfinelinesbyvisuallyfillingingapsusingsurroundingpixels

settointermediateshadesofgrey.IfyouhaveanLCD,forthe

best-lookingfonts,youshoulddefinitelyselectSubpixelasthe

Smoothingsetting.



Hinting



Becausecomputerscreensoperateatamuchlowerresolution

thanwhatweareusedtoseeingwithprintedmaterial,fonts

thatarescaleddowntoasmallsizecansometimessufferfrom

effectswherebytheshapeandpositionofindividualletters

don'tinteractwellwiththepixelstructureofthedisplayitself,

producingvisibleartifacts.Forexample,twolettersnexttoeach

otherthatbothhavethinverticallinesmayhappentofall

slightlydifferentlyontothepixelgridofthedisplay,withthe

resultthatonelineappearsfatterthantheother.Asimilar

effectcanoccurwithroundedletters,wherefinecurvesmay

disappearorbeinconsistent.Oftentherelativeplacementof

letterswillalterthevisualeffectofotherlettersaroundthem.

Hintingistheprocessofmakingtinyadjustmentsintheoutlinefillingprocesswhilerenderingfontstocompensateforeffects

thatmightcauseindividualcharacterstoappeardifferently

fromthewaytheyweredesigned.

Doingaccuratehintingrequiresmoreprocessorpower

wheneveryourcomputerneedstorenderlargequantitiesof

text,buttheendresultistextthatappearssmoother,more

consistentandeasiertoread.Youcanchoosefromfourhinting

levelsinFontRenderingDetails:None,Slight,Medium,and

Full.Thedifferencemightseemsubtleifyou'renotusedto

closelyexaminingtextandyoudon'tknowwhattolookfor,but

ifyouhavearelativelymodernmachine,it'sworthturningon

hinting.LCDsinparticularcanbenefitgreatlyfromit,giving

youmuchmorereadabletextandlesseyestrain.



Subpixelorder

InthemainFontPreferencesdialog,therewasanoptiontoturn

onsubpixelsmoothing,butforittobereallyeffective,youalso

needtomakesureyourcomputerknowsthephysicalstructure

oftheindividualsubpixels.Inreality,subpixelsarenotdots:

they'retypicallyveryshortlinesplacedsidebyside.



ThevastmajorityofLCDsuseanRGBorder,butsomereverse

thatandplacethesubpixelsinBGRorder.Thenthereare

variationsonthosetwooptions,withsomemanufacturers

stackingsubpixelsverticallyinsteadofplacingthemsideby

side.Selectingtheoptionthatmatchesyourparticularmonitor

structurewillletyourcomputerdothebestjobpossibleof

smoothingfontsonscreen.



InstallMicrosoftCoreFonts

MicrosoftWindowscomesbundledwithanumberofcore

TrueTypefonts.BecauseWindowsissowidelyused,many

documentsandwebsitesaredesignedaroundthecore

Microsoftfonts,andifyoudon'thavetheminstalled,your

computermaynotbeabletodisplaysomedocumentsasthe

authorintended.LicencerestrictionspreventtheMicrosoftfonts

frombeingdistributeddirectlyaspartofUbuntu,butMicrosoft

doesmakethemavailableforfreedownloaddirectlyfromits

website,andthereisevenanUbuntupackagethattakescare

ofdownloadingandinstallingthemforyou:

$sudoapt-getinstallmsttcorefonts





Themsttcorefontspackageispartofthemultiverserepository,

soit'snotavailableonastandardUbuntuinstallationandyou

mayneedto"ModifytheListofPackageRepositories"[Hack

#60]beforeyoucaninstallit.

Thepackagedoesn'tincludethefontsthemselvesbutinstead

connectstotheMicrosoftwebsiteanddownloadsandinstalls

theminthecorrectlocationonyourcomputer.Thefontswill

thenbeavailabletoapplicationsthenexttimetheystartup.



InstallMacintoshandWindowsTrueTypeFonts

InstallingTrueTypefontsisveryeasyonUbuntu.Onyour

desktoporinafile-browserwindow,justtypeCtrl-Ltoaccess

theOpenLocationwindow;thentypefonts:///andclickOpen.

Youwillthenseealistofallthefontsyoucurrentlyhaveaccess

toonyoursystem.DragyournewTrueTypefontfromyour

desktoporfilemanagerintothefont-listwindow,anditwillbe

automaticallyinstalledandmadeavailabletoapplications

throughDefomathenexttimetheystartup.

It'sactuallynotquitethatsimpleifthefontscomefroma

Macintoshsystem,becauseMacOSembedsextrafont

informationusingaspecialformatthatLinuxcan'treaddirectly.

BeforeyoudragMacOSfontsintoyourfonts:///folder,you

needtoconvertthemwithautilitycalledfondu,whichyoucan

installwiththefollowingcommand:

$sudoapt-getinstallfondu





ThencopyyourMacOSfontdirectorytoyourLinuxmachine

andrun:

$fondu*





insideittogenerateconvertedTTFfiles.



Thefonts:///locationisn'tareallocationinthefilesystem.It's

avirtualviewthatletsyoumanagethefontsthathavebeen

installedwithouthavingtoworryaboutwheretheyareactually

locatedondisk.Thefontsshownbydefaultarethesystemwidefontsthathavebeeninstalledonyourmachineforall

userstoaccess,butwhenyoudraganewfontintothewindow,

itactuallystoresitinsideahiddenfoldercalled.fontsinside

yourhomedirectory.







Chapter6.PackageManagement

Hacks54-66

OneofUbuntu'skeystrengthsisthequalityofthesoftware

packagesthatareincludedinthemaindistribution:theyhave

beenrelentlesslytested,andcometogethertoformarock-solid

Linuxdistribution.Thesepackagesaremanagedbyatoolcalled

APT(AdvancedPackagingTool)aswellasavarietyoffrontends

thatmakeaptabiteasiertoworkwith.Inthischapter,you'll

learnhowtoworkwithaptandthosefrontends.

AlthoughthemainUbuntudistributionisintegratedandvery

solid,thatstabilitycomesataprice:manyoftheoptional

packagesyoumaywanthavebeenexcludedfromthemain

distribution.However,therearemanywaystobringinoptional

packages,andtherearehacksinthischaptertohelpyoudoso.

Thesehackswillalsohelpyouunderstandtheconsequencesof

addingoptionalpackages.You'llalsolearnhowtocompile

applicationsfromsource,createyourownUbuntupackages,

andhostpackagesinacustomrepositoryforotherstouse.







Hack54.ManagePackagesfromtheCommand

Line



Diveunderthehoodandmanagepackagesdirectlyfrom

thecommandline.

Ubuntuprovidesanumberofverynicegraphicaltoolsfor

managingsoftwarepackagesfromthedesktop,butsometimes

youjusthavetogethands-ontoreallygetthingsdone.Servers

don'tgenerallyhaveagraphicaldesktopenvironmentinstalled,

andifyoumanagemachinesremotelythroughashellsession,

youneedtoknowhowtouseUbuntu'scommand-linepackagemanagementtools.

Ubuntustrivesforconsistencyintheprocessofmanaging

software.Allsoftwareispackagedusingastrictlydefined

formatthatcontainstheprogramitselfplusinformationabout

howitneedstobeinstalled,andallpackagesarestoredon

yourcomputerintheexactsameway.Thepackagemanagementtoolsarelayered,witheachlayerbuildingonthe

levelsbelow.Atthelowestlevelisdpkg,whichdirectly

managespackages;mid-leveltoolslikeaptsitondpkgand

providemorefunctionality,suchasautomaticdependency

resolution;andhigh-leveltoolslikeSynapticandAdeptsiton

aptandletyougraphicallybrowsepackagelistsanddosimple

point-and-clickinstallation.



dpkg

dpkgisthebasisoftheDebianpackage-managementsystem

andallowsdirectmanipulationofpackages.Ifyouhavealocal



packageondiskcalledprogram-1.0-1.debthatyouwantto

install,dpkgisthetooltouse.Becauseit'ssuchanimportant

partofthepackage-managementstack,ithasawholehackof

itsown[Hack#57].



aptandFriends

Whileitwasnotoriginallyintendedasafrontendtool,but

ratherasanintermediatelayerbetweendpkgandend-user

toolssuchasSynapticandAdept,runningaptdirectlyis

probablythemostcommonmethodformanagingpackageson

thecommandline.

Somecommandsrequirerootprivileges,soyouneedto

prependthemwithsudoifyou'rerunningasanunprivileged

user.

Herearesomecommandsyou'llwonderhowyoueverlived

without:



Retrievethecurrentlistofpackagesfromallservers

Ifyoudon'tdothisfromtimetotime,yourlocallistof

availablepackagesmaybecomeoutofdate.Runthis

commandoccasionallybeforedoingadist-upgradeor

searchingforanewpackage.Thepackagelistsarelarge,

anddoinganupdatemayresultinseveralMBofdatabeing

retrievedfromtheInternet:

$sudoapt-getupdate





Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Hack 53. Make Your Fonts Pretty

Tải bản đầy đủ ngay(0 tr)

×